<!DOCTYPE html>
<!-- ng-app -->
<html lang="en" ng-app="app">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="../../../js/plugins/angular/angular.min.js" type="text/javascript"></script>
</head>
<body>
    <div ng-controller="cont">
        <div class="show">{{str('我都是服务返回的内容')}}</div>
        <div class="show">{{name(1)}}</div>
    </div>

    <script>
        angular.module('app',[])
            .factory('$outfun',function () {
                return {
                    str:function (s) {
                        return s;
                    }
                }
            })
            .factory('$outarr',function () {
                return ['张三','李四','王二']
            })
            .controller('cont',function ($scope,$outfun,$outarr) {
                $scope.str = function (n) {
                    return $outfun.str(n);
                }
                $scope.name = function (n) {
                    return $outarr[n];
                }
            })

    </script>
</body>
</html>